/*package org.qs.webservice.controller;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.FormParam;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;

import org.apache.log4j.Logger;
import org.jdom.JDOMException;
import org.qs.webservice.exception.QSReadException;
import org.qs.webservice.service.CertPayService;
import org.qs.webservice.util.IReadUtils;
import org.qs.wx.handler.ResponseHandler;
import org.qs.wx.handler.util.ConstantUtil;
import org.qs.wx.handler.util.XMLUtil;
import org.springframework.stereotype.Component; 



*//**
 * 获取某个区块中素材列表接口
 * @ClassName: BlockRestController 
 * @author xusaike 
 * @date 2015年9月28日 下午2:39:54 
 *
 *//*
@Component
@Path("/cert/pay")
public class CertPayRestController {

	@Resource
	CertPayService certPayService;
	private static Logger logger = Logger.getLogger(CertPayRestController.class);  
	*//**
	 * 生成支付订单
	 * @Title: addOrder 
	 * @param charge_fee 价格  单位为分
	 * @param payType  付费类型
	 * @param spType
	 * @param mobileNum
	 * @param productName
	 * @param productDesc
	 * @param others
	 * @param token
	 * @return   
	 * @return String    
	 * @throws
	 *//*
	@POST 
	@Produces(javax.ws.rs.core.MediaType.TEXT_PLAIN)  
	public String addOrder(@FormParam("productId")String productId,
			@FormParam("spbill_create_ip")String spbill_create_ip,
			
			@HeaderParam("token")String token,
			@Context HttpServletRequest request,
			@Context HttpServletResponse response
			){
		try{
			String addmessage =certPayService.addOrder(token,productId,spbill_create_ip,request,response);
			return addmessage;
		} catch (Exception e) {
			Map<String,Object> errorJson = new HashMap<String,Object>();
			errorJson.put("productId", productId);
			
			errorJson.put("token", token);
			QSReadException.printf(e, "生成订单异常！",errorJson);
		}
		Map<String,Object> tokenMap = new HashMap<String,Object>();
		Map<String,Object> error = new HashMap<String,Object>();
		error.put("error", "服务器错误");
		List<Map<String, Object>> list = new ArrayList<Map<String,Object>>();
		list.add(error);
		tokenMap.put("code", 403);
		tokenMap.put("error",list);	
		return IReadUtils.beanToJson(tokenMap);
	}
	@SuppressWarnings("rawtypes")
	@POST 
	@Produces(javax.ws.rs.core.MediaType.TEXT_PLAIN)  
	@Path("/result")
	public String result(@Context HttpServletRequest request,
			@Context HttpServletResponse response){
		StringBuffer sb = new StringBuffer() ; 
		InputStream is = null;
		try {
			is = request.getInputStream();
		} catch (IOException e1) {
			e1.printStackTrace();
		} 
		InputStreamReader isr = new InputStreamReader(is);   
		BufferedReader br = new BufferedReader(isr); 
		String s = "" ; 
		try {
			while((s=br.readLine())!=null){ 
			sb.append(s) ; 
			}
		} catch (IOException e1) {
			e1.printStackTrace();
		} 
		Map map = null;
		try {
			map = XMLUtil.doXMLParse(sb.toString());
		} catch (JDOMException e1) {
			e1.printStackTrace();
		} catch (IOException e1) {
			e1.printStackTrace();
		}
		//创建支付应答对象
		ResponseHandler resHandler = new ResponseHandler(request, response,map);
		resHandler.setKey(ConstantUtil.APP_KEY);
		//判断签名
		if(resHandler.isTenpaySign()) {
				//判断签名及结果
				if( "SUCCESS".equals(resHandler.getParameter("return_code")) && "SUCCESS".equals(resHandler.getParameter("result_code")) ) {
					logger.info(IReadUtils.beanToJson(map));
					//------------------------------
					//处理业务开始
					//------------------------------
					
					//处理数据库逻辑
					certPayService.updateOrder( resHandler.getParameter("out_trade_no"),  resHandler.getParameter("result_code"));
				
					//注意交易单不要重复处理
					//注意判断返回金额
					
					//------------------------------
					//处理业务完毕
					//------------------------------
					
					return "<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>";
				}else{
						//错误时，返回结果未签名，记录retcode、retmsg看失败详情。
					logger.error("查询验证签名失败或业务错误");
					logger.error(IReadUtils.beanToJson(map));
				}
			
		
		}else{
			logger.error("通知签名验证失败");
			logger.error(IReadUtils.beanToJson(map));
		}
		return "<xml><return_code><![CDATA[FAIL]]></return_code><return_msg><![CDATA[签名失败]]></return_msg></xml>";
		
	}
	
		


}*/